/* 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 3 of the License, or 
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License along 
 * with this program; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#ifndef WISHMASTER_POST_H
#define WISHMASTER_POST_H

#include <QMap>
#include <QSet>
#include <QPixmap>
#include <QDateTime>
#include <QSharedPointer>
#include "extrainfo.h"
#include "extracontainer.h"
#include "threadptr.h"
#include "attachment.h"
#include "postid.h"
#include "misc.h"
#include "componentvisibility.h"

namespace Wishmaster
{
	class Thread;
	class WISHMASTER_EXPORT Post
	{
	public:
		Post(const PostId& postId);
		virtual ~Post();

		void setText(const QString& text);
		QString const& text();

		bool hasImages();

		void setTopic(const QString& topic);
		QString const& topic();

		PostId id();

		void setName(const QString& name);
		QString name();

		void setTimestamp(const QDateTime& dt);
		QDateTime timestamp() const;

		void setExtra(const QString& key, ExtraInfo info);
		ExtraInfo extra(const QString& key) const;
		QStringList extraList();
		ExtraContainer extraContainer();

		void setVisibility(ComponentVisibility newVisibility);
		ComponentVisibility visibility() const;

		void setExpanded(bool e);
		bool isExpanded();

		void addReply(const PostId& id);
		QList<PostId> replies();
		void clearReplies();

		int attachmentCount();
		AttachmentPtr attachment(int index);
		void addAttachment(const AttachmentPtr& attach);

		typedef PostId IdType;
	private:
		QString m_text;
		QString m_topic;
		QString m_name;
		PostId m_id;
		ExtraContainer m_extra;
		QList<PostId> m_replies;
		QList<AttachmentPtr> m_attachments;
		bool m_expanded;
		ComponentVisibility m_visibility;
		QDateTime m_timestamp;
	};

	typedef QSharedPointer<Post> PostPtr;
}

#endif

